home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AGA Toolkit '97
/
The AGA Toolkit '97.iso
/
graphics
/
misc
/
spp
/
spp.doc
< prev
Wrap
Text File
|
1996-09-07
|
7KB
|
221 lines
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
S + P I M A G E C O M P R E S S I O N P R O G R A M
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
< ANSI C > version 1.09 - 02/01/96
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Copyright (c) 1996 by Amir Said & William A. Pearlman
DESCRIPTION
===========
The program "spp" contains an encoder and decoder for lossy and
lossless compression of grayscale or color images. Its main purpose
is the lossless compression of natural, scientific, database,
multispectral, elevation maps, etc., images. In the lossless mode
it has full verification of the image integrity (including the header
and its comments, title, etc.).
It supports images originally scanned with up to 16 bits/pixel/color,
accepts some well-known image header and formats, and up to 256 "color
dimensions" (1 for greyscale, 3 for RGB, 4 for CMYK, n for multispectral).
The source code is available to those that need to compress images with
special features and formats. It was written to be simple and fast, and
not use any patented algorithm. Under such conditions it cannot represent
the state-of-the-art for all cases, but it is quite good for regular use.
(Please do not use it for comparisons!)
As an extra feature, the program allows some limited forms of lossy
compression. It is quite efficient for the "near-lossless" compression
of graylevel images, and can give users the opportunity to see how
their images are affected by moderate lossy compression. It uses a
wavelet-based compression method and the recovered lossy images
tend to look quite good, with nearly uniform-distributed errors.
For those that are not coding specialists it should be stressed that
higher compression ratios MUST yield large approximation errors,
which are unevenly distributed throughout the image, and can be
unacceptable for images that are meant to be processed (instead of
just looked at). If for your images large error are acceptable, you
may consider other compression programs.
In the lossy mode it compresses the color components separately. This
is not the most efficient scheme, but it the only one that can be used
when the color space is not known, and when the components may not
represent true colors.
USAGE
=====
Only one program is used for coding and decoding, and the file name
extension is used to identify the type of image. The usage to encode
images with a known header is
> spp file_name.ext [lossy_compression_factor]
(Arguments between [ ] are optional.)
The presently accepted extension are
.ras -> SUN rasterfile format, 8 and 24 bpp images
.pgm -> "portable graymap format" - grayscale raw images
.ppm -> "portable pixmap format" - color raw images
The encoder changes the extension and writes to the compressed file
"file_name.spc". The lossy compression factor is a number between
0 and 12, with 0 for lossless compression and 12 for maximum lossy
compression. The default value is 0.
As a rule-of-thumb, for values smaller than 7 the lossy compression
factor represents the expected maximum magnitude of the reconstruction
error.
To recover a compressed image use
> spp file_name.spc
If the original file exists in the same directory the decoder will
ask if it can be overwritten.
The program can compress images without header if their name
extension is ".raw". The usage is
> spp file_name.raw width [height] [bits/pixel] [lossy_factor]
Here the last parameters are optional, but they should be typed
up to the parameter that is not meant to be the default. The
parameter bits/pixel correspond to the original image (not the
compressed).
The defaults are:
height = width
bits/pixel = 8
lossy_factor = 0
REMARKS
=======
(1) The header is copied (byte-by-byte) to the compressed file,
and then copied back to the recovered file. In the lossless mode
32 bits CRC error detection is used to assure the image integrity
(including header).
(2) The program was not designed to code to rates near or below
0.5 bpp. So, it becomes less efficient for very smooth image or
when the lossy compression factor is near its maximum.
(3) The memory usage is relatively small because only a "slice" of
the image (with 32 pixels of height) is kept in memory at each time.
If necessary, the memory utilization can be optimized by changing
the following definition of type "Pic" in file "spp_code.h":
typedef long Pic;
The required space is:
original size "Pic" size type (depending on compiler)
<= 11 bpp 16 bits short or int
>= 12 bpp 32 bits long or int
EXAMPLES
========
(1) To compress "lena" in Sun's rasterfile format just type
> spp lena.ras
and to recover
> spp lena.spc
(2) To compress "lena" 512x512, 8 bpp, in raw format
> spp lena.raw 512
or
> spp lena.raw 512 512 8 1 0
and to recover just type (note that the decoder recovers
to the original format and extension)
> spp lena.spc
(3) Lossy compression of lena
> spp lena.ras 5
or
> spp lena.raw 512 512 8 1 5
Recovery in both cases
> spp lena.spc
COMPILATION
===========
For UNIX compilation with GNU's gcc compiler the program comes with
a script file called "compile". So, just type "compile" at the prompt
to execute
gcc -O2 -o spp spp_main.c spp_proc.c
The option O2 is used to call the optimizing compiler.
ALGORITHM
=========
The compression algorithm uses the S+P transform (Said & Pearlman,
SPIE VCIP Symposium, Cambridge, MA, Nov. 1993) and Huffman coding
working on groups of 2x2 pixels (to allow coding rates below 1 bpp).
CONTACT
=======
Amir Said: amir@densis.fee.unicamp.br
DENSIS - Faculty of Electrical Engineering
University of Campinas (UNICAMP)
Campinas, SP 13081, Brazil
William A. Pearlman - pearlman@ecse.rpi.edu
Dept. of Electrical, Computer, and Systems Engineering
Rensselaer Polytechnic Institute
Troy, NY 12180, USA
CONTRIBUTIONS
=============
Suggestions for program modifications are welcome! Let us know
if you improved the program, added (or want to add) a new header
format, etc.
COPYRIGHT
=========
This program is Copyright (c) by Amir Said & William A. Pearlman.
It can be freely copied and used for personal use, but it
should not be copied, redistributed, edited, sold for profit, or
incorporated in commercial programs without the written permission
of the copyright holders. This program is provided as is, without
any express or implied warranty, without even the warranty of
fitness for a particular purpose.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -